package ITSBank;

import java.util.ArrayList;

/**
 * This class represents a single bank in the 'ITS-Bank-World'
 * @author Benedikt Gschossmann
 */
public class Bank {
    private int BankID;
    private String BankName;
    private ArrayList<Customer> Customers;
    private ArrayList<Account> Accounts;

    /**
     * Constructor for class Bank
     */
    Bank (int bankID, String bankName){
        this.BankID = bankID;
        this.BankName = bankName;
        this.Accounts = new ArrayList();
        this.Customers = new ArrayList();
    }

    /**
     * get-method for Account
     * @return Account
     */
    public Account getAccount(int AccountID) {
        return this.Accounts.get(AccountID);
    }
    /**
     * get-method for Customer
     * @return Customer
     */
    public Customer getCustomer(int CustomerID) {
        return this.Customers.get(CustomerID);
    }
    /**
     * get-method for bankID
     * @return ID of the bank
     */
    public int getBankID () {
        return BankID;
    }

    /**
     * get-method for bankName
     * @return name of the bank
     */
    public String getBankName () {
        return BankName;
    }

    /**
     * get-method for number of account in bank
     * @return number of accounts in the bank
     */
    public int getAccountsN(){
        return this.Accounts.size();
    }

    /**
     * get-method for number of account in bank
     * @return number of accounts in the bank
     */
    public int getCustomersN(){
        return this.Customers.size();
    }
    /**
     * This method displays all customers of the bank (??? same as displayAccounts)
     */
    public void displayCustomers () {
        //TODO: iterate over list and call display function
    }

    /**
     * This method displays all accounts of the bank (??? same as displayAccounts)
     */
    public void displayAccounts () {
        //TODO: iterate over list and call display function
    }

    /**
     * This method creates a new account.
     * Different types:
     *      type == 1: SavingAccount
     *      type == 2: CheckingAccount
     *      type == 3: CustodyAccount
     * @param Customer who creates the account
     * @param startingBalance
     * @param account type
     */


//    public static void newCheckAccount(Bank bank, int customerID){

//        Account tempaccount = new CheckingAccount(this.Customers.get(customerID) ,123,this.getAccountsN());
//bank.Accounts.add(tempaccount);
//bank.Customers.get(customerID).account = tempaccount;
    //}

    public void createAccount (int type, int customerID) {

        CheckingAccount tempaccount = new CheckingAccount(this.Customers.get(customerID),this.getAccountsN());
this.Accounts.add(tempaccount);
System.out.println("Your new accountID: "+tempaccount.getAccountNumber());
this.Customers.get(customerID).addAccount(tempaccount.getAccountNumber());

    }

    /**
     * This method adds a new customer to the bank
     * @param the new customer
     */
//public Customer(int cID, String cName, String cAddress, int cBank)
    public void newCustomer(String name,String address){
        Customer tempcustomer = new Customer(this.getCustomersN(),name,address,this);
        this.Customers.add(tempcustomer);
        System.out.println("\nYour PIN: "+tempcustomer.getPIN());
        System.out.println("Your ID: "+tempcustomer.getCustomerID());
    }

    public void addCustomer (Customer newCustomer) {
        newCustomer.setCustomerBank(this);
        newCustomer.setCusomerID(this.getCustomersN());
this.Customers.add(newCustomer);
    }

    
}

